<?php
/**
 * Created by IntelliJ IDEA.
 * User: skyADMIN
 * Date: 15/9/17
 * Time: 下午1:27
 */
session_start();
require_once ('connect.php');

$action = $_GET['action'];
if($action == 'record'){
    $user = $_SESSION['user'];
    $number = stripslashes(trim($_POST['number']));
    $correctrate = stripslashes(trim($_POST['correctrate']));
    $datetime = stripslashes(trim($_POST['datetime']));
    $level = stripslashes(trim($_POST['level1']));
    $model = stripslashes(trim($_POST['model']));
    $sql = "insert into information(username,time,number,correctrate,mode,level) VALUE ('$user','$datetime','$number','$correctrate','$model','$level')";
    //echo $sql;
    $r_query = mysql_query($sql);
    echo 1;
}else if($action == 'load'){
    $user = $_SESSION['user'];
    $sql = "select * from information WHERE username='$user' ORDER BY eid DESC";
    $result = mysql_query($sql);
    echo "<table class='table table-striped'><tr><th>做题时间</th><th>做题模式</th><th>做题难度</th><th>做题数量</th><th>正确率</th></tr>";
    $i = 0;
    while($row = mysql_fetch_array($result))
    {
        $i++;
        if($i == 11){
            break;
        }
        echo "<tr><td>".$row['time']."</td><td>".$row['mode']."</td><td>".$row['level']."</td><td>".$row['number'].'</td><td id="correctrateData'.$i.'">'.$row['correctrate']."</td></tr>";
    }
}
?>